
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>common2模块 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="spring.html" />
    
    
    <link rel="prev" href="common.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    概要
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1.1" data-path="../architecture.html">
            
                <a href="../architecture.html">
            
                    
                    总体架构
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../quick-start.html">
            
                <a href="../quick-start.html">
            
                    
                    快速开始
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../quickstart/confcenter.html">
            
                <a href="../quickstart/confcenter.html">
            
                    
                    配置中心
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../quickstart/oneplatform.html">
            
                <a href="../quickstart/oneplatform.html">
            
                    
                    oneplatform企业级开发平台
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../quickstart/passport.html">
            
                <a href="../quickstart/passport.html">
            
                    
                    统一认证平台
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../jeesuite-lib.html">
            
                <a href="../jeesuite-lib.html">
            
                    
                    jeesuite-libs使用文档
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="common.html">
            
                <a href="common.html">
            
                    
                    common模块
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.3.2" data-path="common2.html">
            
                <a href="common2.html">
            
                    
                    common2模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="spring.html">
            
                <a href="spring.html">
            
                    
                    Spring模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="mybatis.html">
            
                <a href="mybatis.html">
            
                    
                    mybatis模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="cache.html">
            
                <a href="cache.html">
            
                    
                    cache模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.6" data-path="kafka.html">
            
                <a href="kafka.html">
            
                    
                    kafka模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.7" data-path="scheduler.html">
            
                <a href="scheduler.html">
            
                    
                    scheduler模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.8" data-path="filesystem.html">
            
                <a href="filesystem.html">
            
                    
                    filesystem模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.9" data-path="rest.html">
            
                <a href="rest.html">
            
                    
                    restAPI模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.10" data-path="springboot-starter.html">
            
                <a href="springboot-starter.html">
            
                    
                    springboot-starter模块
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../integration.html">
            
                <a href="../integration.html">
            
                    
                    系统集成
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../integration/confcenter.html">
            
                <a href="../integration/confcenter.html">
            
                    
                    集成配置中心
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../integration/passport.html">
            
                <a href="../integration/passport.html">
            
                    
                    集成认证中心
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../base-env-install.html">
            
                <a href="../base-env-install.html">
            
                    
                    附：基础环境搭建
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >common2模块</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h3 id="&#x529F;&#x80FD;&#x8BF4;&#x660E;">&#x529F;&#x80FD;&#x8BF4;&#x660E;</h3>
<p>common2&#x4E5F;&#x662F;&#x5DE5;&#x5177;&#x7C7B;&#xFF0C;&#x8F83;common&#x6A21;&#x5757;&#x91CD;&#x91CF;&#x7EA7;&#x4E00;&#x4E9B;&#xFF0C;&#x9700;&#x8981;&#x4F9D;&#x8D56;&#x7B2C;&#x4E09;&#x65B9;&#x73AF;&#x5883;&#x5982;&#xFF1A;redis&#x3001;zookeeper&#x7B49;&#xFF0C;&#x6545;&#x4E0E;common&#x5206;&#x5F00;&#x3002;&#x76EE;&#x524D;&#x5B9E;&#x73B0;&#x4E86;&#xFF1A;&#x5168;&#x5C40;ID&#x751F;&#x6210;&#x5668;&#x3001;&#x5206;&#x5E03;&#x5F0F;&#x9501;(redis&#x7248;&#x3001;zookeeper&#x7248;)&#x3001;excel&#x5DE5;&#x5177;&#x3002;</p>
<h3 id="&#x4F7F;&#x7528;&#x8BF4;&#x660E;">&#x4F7F;&#x7528;&#x8BF4;&#x660E;</h3>
<h4 id="&#x6DFB;&#x52A0;&#x4F9D;&#x8D56;">&#x6DFB;&#x52A0;&#x4F9D;&#x8D56;</h4>
<pre><code>&lt;dependency&gt;
    &lt;groupId&gt;com.jeesuite&lt;/groupId&gt;
    &lt;artifactId&gt;jeesuite-common2&lt;/artifactId&gt;
    &lt;version&gt;[&#x6700;&#x65B0;&#x7248;&#x672C;]&lt;/version&gt;
&lt;/dependency&gt;
</code></pre><h3 id="&#x5168;&#x5C40;id&#x751F;&#x6210;&#x5668;">&#x5168;&#x5C40;Id&#x751F;&#x6210;&#x5668;</h3>
<p>&#x76EE;&#x524D;&#x53EA;&#x5B9E;&#x73B0;&#x57FA;&#x4E8E;Snowflake&#x7B97;&#x6CD5;&#x751F;&#x6210;&#x5668;&#xFF0C;&#x540E;&#x7EED;&#x65B0;&#x589E;&#x57FA;&#x4E8E;&#x6570;&#x636E;&#x5E93;sequence&#x7684;&#x3002;</p>
<pre><code class="lang-java">SnowflakeGenerator generator = <span class="hljs-keyword">new</span> SnowflakeGenerator(<span class="hljs-string">&quot;127.0.0.1:2181&quot;</span>);
<span class="hljs-keyword">long</span> id = generator.nextId();
System.out.println(id);
</code></pre>
<h3 id="&#x5206;&#x5E03;&#x5F0F;&#x9501;">&#x5206;&#x5E03;&#x5F0F;&#x9501;</h3>
<pre><code class="lang-java"><span class="hljs-comment">//redis</span>
<span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">run</span><span class="hljs-params">()</span> </span>{
    RedisDistributeLock lock = <span class="hljs-keyword">new</span> RedisDistributeLock(<span class="hljs-string">&quot;test&quot;</span>);
    <span class="hljs-comment">//boolean getLock = lock.tryLock(5, TimeUnit.SECONDS);</span>
    lock.lock();
    System.out.println(<span class="hljs-string">&quot;LockWorker[&quot;</span> + id + <span class="hljs-string">&quot;] get lock,doing&quot;</span>);
    <span class="hljs-keyword">try</span> {
        Thread.sleep(RandomUtils.nextLong(<span class="hljs-number">1000</span>, <span class="hljs-number">10000</span>));
    } <span class="hljs-keyword">catch</span>(Exception e) {}
    lock.unlock();
    latch.countDown();
    System.out.println(<span class="hljs-string">&quot;LockWorker[&quot;</span> + id + <span class="hljs-string">&quot;] release lock,done&quot;</span>);
}

<span class="hljs-comment">//zookeeper</span>
<span class="hljs-meta">@Override</span> <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">run</span><span class="hljs-params">()</span> </span>{
    ZkDistributeLock lock = <span class="hljs-keyword">new</span> ZkDistributeLock(<span class="hljs-string">&quot;127.0.0.1:2181&quot;</span>, <span class="hljs-string">&quot;test&quot;</span>);
    lock.lock();
    System.out.println(<span class="hljs-string">&quot;LockWorker[&quot;</span> + id + <span class="hljs-string">&quot;] get lock,doing&quot;</span>);
    <span class="hljs-keyword">try</span> {
        Thread.sleep(<span class="hljs-number">2000</span>);
    } <span class="hljs-keyword">catch</span>(Exception e) {}
    lock.unlock();
    latch.countDown();
    System.out.println(<span class="hljs-string">&quot;LockWorker[&quot;</span> + id + <span class="hljs-string">&quot;] release lock,done&quot;</span>);
}
</code></pre>
<h3 id="excel&#x64CD;&#x4F5C;">excel&#x64CD;&#x4F5C;</h3>
<p>&#x63D0;&#x4F9B;poi&#x7528;&#x6237;&#x6A21;&#x5F0F;&#x64CD;&#x4F5C;&#x5C01;&#x88C5;&#x4EE5;&#x53CA;&#x5927;&#x6570;&#x636E;&#x91CF;&#x6027;&#x80FD;&#x6A21;&#x5F0F;&#x8BFB;&#x53D6;&#x65B9;&#x5F0F;&#x3002;</p>
<pre><code class="lang-java"><span class="hljs-comment">//&#x6570;&#x636E;&#x6A21;&#x578B;</span>
<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">PersonSalaryInfo</span> </span>{

    <span class="hljs-meta">@TitleCell</span>(name=<span class="hljs-string">&quot;*&#x59D3;&#x540D;&quot;</span>,column = <span class="hljs-number">1</span>,notNull = <span class="hljs-keyword">true</span>)
    <span class="hljs-keyword">private</span> String name;
    <span class="hljs-meta">@TitleCell</span>(name=<span class="hljs-string">&quot;&#x90E8;&#x95E8;&quot;</span>,column = <span class="hljs-number">2</span>)
    <span class="hljs-keyword">private</span> String department;
    <span class="hljs-meta">@TitleCell</span>(name=<span class="hljs-string">&quot;&#x8EAB;&#x4EFD;&#x8BC1;&#x53F7;&quot;</span>,column = <span class="hljs-number">3</span> )
    <span class="hljs-keyword">private</span> String idCard;
    <span class="hljs-meta">@TitleCell</span>(name=<span class="hljs-string">&quot;&#x57FA;&#x672C;&#x5DE5;&#x8D44;&quot;</span>,column = <span class="hljs-number">4</span>,row = <span class="hljs-number">2</span>,parentName = <span class="hljs-string">&quot;&#x5E94;&#x53D1;&#x5DE5;&#x8D44;&quot;</span>,type = Float.class)
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">float</span> baseSalary;<span class="hljs-comment">//&#x57FA;&#x672C;&#x5DE5;&#x8D44;</span>
    <span class="hljs-meta">@TitleCell</span>(name=<span class="hljs-string">&quot;&#x5C97;&#x4F4D;&#x5DE5;&#x8D44;&quot;</span>,column = <span class="hljs-number">5</span>,row = <span class="hljs-number">2</span>,parentName = <span class="hljs-string">&quot;&#x5E94;&#x53D1;&#x5DE5;&#x8D44;&quot;</span>,type = Float.class)
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">float</span> postSalary;<span class="hljs-comment">//&#x5C97;&#x4F4D;&#x5DE5;&#x8D44;</span>
    <span class="hljs-meta">@TitleCell</span>(name=<span class="hljs-string">&quot;&#x7EE9;&#x6548;&#x5DE5;&#x8D44;&quot;</span>,column = <span class="hljs-number">6</span>,row = <span class="hljs-number">2</span>,parentName = <span class="hljs-string">&quot;&#x5E94;&#x53D1;&#x5DE5;&#x8D44;&quot;</span>,type = Float.class)
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">float</span> performSalary;<span class="hljs-comment">//&#x7EE9;&#x6548;&#x5DE5;&#x8D44;</span>
    <span class="hljs-meta">@TitleCell</span>(name=<span class="hljs-string">&quot;&#x798F;&#x5229;&#x6D25;&#x8D34;&quot;</span>,column = <span class="hljs-number">7</span>,row = <span class="hljs-number">2</span>,parentName = <span class="hljs-string">&quot;&#x5E94;&#x53D1;&#x5DE5;&#x8D44;&quot;</span>,type = Float.class)
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">float</span> subsidies;<span class="hljs-comment">//&#x798F;&#x5229;&#x6D25;&#x8D34;</span>
    <span class="hljs-meta">@TitleCell</span>(name=<span class="hljs-string">&quot;&#x6263;&#x9664;&#x91D1;&#x989D;&quot;</span>,column = <span class="hljs-number">8</span>,row = <span class="hljs-number">2</span>,parentName = <span class="hljs-string">&quot;&#x5E94;&#x53D1;&#x5DE5;&#x8D44;&quot;</span>,type = Float.class)
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">float</span> deductSalary; <span class="hljs-comment">//&#x6263;&#x9664;&#x91D1;&#x989D;</span>
    <span class="hljs-meta">@TitleCell</span>(name=<span class="hljs-string">&quot;*&#x603B;&#x8BA1;&quot;</span>,column = <span class="hljs-number">9</span>,row = <span class="hljs-number">2</span>,parentName = <span class="hljs-string">&quot;&#x5E94;&#x53D1;&#x5DE5;&#x8D44;&quot;</span>,notNull = <span class="hljs-keyword">true</span>,type = Float.class)
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">float</span> total;
    <span class="hljs-meta">@TitleCell</span>(name=<span class="hljs-string">&quot;*&#x793E;&#x4FDD;&#x57FA;&#x6570;&quot;</span>,column = <span class="hljs-number">10</span>,notNull = <span class="hljs-keyword">true</span>,type = Float.class)
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">float</span> insuranceBase;<span class="hljs-comment">//&#x793E;&#x4FDD;&#x57FA;&#x6570;</span>
    <span class="hljs-meta">@TitleCell</span>(name=<span class="hljs-string">&quot;*&#x516C;&#x79EF;&#x91D1;&#x57FA;&#x6570;&quot;</span>,column = <span class="hljs-number">11</span>,notNull = <span class="hljs-keyword">true</span>,type = Float.class)
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">float</span> housefundBase;
}

<span class="hljs-comment">//</span>
<span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title">main</span><span class="hljs-params">(String[] args)</span> <span class="hljs-keyword">throws</span> InvalidFormatException,IOException </span>{
    <span class="hljs-comment">//&#x666E;&#x901A;&#x65B9;&#x5F0F;&#x8BFB;&#x53D6;</span>
    String excelFilePath = <span class="hljs-string">&quot;/Users/jiangwei/Desktop/&#x5DE5;&#x8D44;.xlsx&quot;</span>;
    ExcelReader excelReader = <span class="hljs-keyword">new</span> ExcelReader(excelFilePath);
    excelReader.parse(PersonSalaryInfo.class);
    excelReader.close();
    <span class="hljs-comment">//&#x5927;&#x6587;&#x4EF6;&#x8BFB;&#x53D6;&#x9632;&#x6B62;&#x5185;&#x5B58;&#x6EA2;&#x51FA;</span>
    List &lt; PersonSalaryInfo &gt; list = <span class="hljs-keyword">new</span> ExcelPerfModeReader(excelFilePath).read(PersonSalaryInfo.class);

    <span class="hljs-comment">//write</span>
    ExcelWriter writer = <span class="hljs-keyword">new</span> ExcelWriter(<span class="hljs-string">&quot;/Users/jiangwei/Desktop/&#x5DE5;&#x8D44;bak.xlsx&quot;</span>);
    writer.write(list, PersonSalaryInfo.class);
    writer.close();
}
</code></pre>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="common.html" class="navigation navigation-prev " aria-label="Previous page: common模块">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="spring.html" class="navigation navigation-next " aria-label="Next page: Spring模块">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"common2模块","level":"1.3.2","depth":2,"next":{"title":"Spring模块","level":"1.3.3","depth":2,"path":"jeesuite-libs/spring.md","ref":"jeesuite-libs/spring.md","articles":[]},"previous":{"title":"common模块","level":"1.3.1","depth":2,"path":"jeesuite-libs/common.md","ref":"jeesuite-libs/common.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"jeesuite-libs/common2.md","mtime":"2017-09-11T01:44:51.000Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-05-04T10:30:11.187Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

